from turtle import *
from math import sqrt
from random import random, randint
class Heart:
    def __init__(self, x, y, size):
        self.size = size    
        self.speed = size   
        t = Turtle(visible=False, shape='circle')
        t.shapesize(size, size)
        color = (1, 1- size/4, 1-size/4)    
        t.pencolor(color)
        t.fillcolor(color)
        t.penup()
        self.circle1 = t.clone()
        self.circle1.goto(x-sqrt(size*size*160)/2, y)
        self.circle2 = t.clone()
        self.circle2.goto(x+sqrt(size*size*160)/2, y)
        self.square = t.clone()
        self.square.shape("square")
        self.square.setheading(45)
        self.square.goto(x, y-sqrt(size * size * 160)/2)
        self.circle1.showturtle()
        self.circle2.showturtle()
        self.square.showturtle()
    def move(self):
        self.circle1.setx(self.circle1.xcor()-self.speed)
        self.square.setx(self.square.xcor() - self.speed)
        self.circle2.setx(self.circle2.xcor() - self.speed)
    def moveTo(self, x, y):
        self.circle1.hideturtle()
        self.circle2.hideturtle()
        self.square.hideturtle()
        self.circle1.goto(x - sqrt(self.size * self.size * 160) / 2, y)
        self.circle2.goto(x + sqrt(self.size * self.size * 160) / 2, y)
        self.square.goto(x, y - sqrt(self.size * self.size * 160) / 2)
        self.circle1.showturtle()
        self.circle2.showturtle()
        self.square.showturtle()
width, height = 800, 600
screen = Screen()     
screen.setup(width, height)    
screen.delay(0)    
screen.bgcolor('pink')   
hearts = []
for i in range(25):
    heart = Heart(width/2 + randint(1, width), randint(-height/2,height/2), random()*3)
    hearts.append(heart)
while True:
    for heart in hearts:
        heart.move()
        if heart.square.xcor() < -width / 2:   
            heart.moveTo(width / 2 + randint(1, width), randint(-height / 2, height / 2))  
